package com.charlotte.study.gupao.prototype.deep.json;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author junjie.ding
 * @date 2020/3/2
 */
@Data
public class ConcretePrototype implements Cloneable, Serializable {

    private int age;
    private String name;
    private List<String> hobbies;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public ConcretePrototype deepClone(){
        String json = JSON.toJSONString(this);
        ConcretePrototype prototype = JSON.parseObject(json, this.getClass());
        return prototype;
    }
}
